package com.example.demo.admin.controller;/**
 * Created by kete on 2017-09-20.
 */

/**
 * 作者：kete
 * 创建时间：2017-09-20 15:22
 * 功能描述：
 * 版本：
 */

import com.example.demo.admin.client.TestServiceClient;
import com.example.demo.common.persistence.model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RefreshScope
@Controller
public class TestController {

    private Logger log = LoggerFactory.getLogger(TestController.class);

    @Autowired
    private TestServiceClient service;


    @Value("${username}")
    private String temp;



    @RequestMapping("/test/index")
    public String index(ModelMap model){
        model.put("hello","hello "+temp);

        log.info(temp);


        return "/index.html";
    }


    @RequestMapping("/test/getUserInfo")
    @ResponseBody
    public User getUserInfo(){

        return service.getUserInfo();

    }
}
